import request from '@/utils/request'
import store from '@/store'
import { isTeacher } from '@/utils/permission'

export default {
    pageClass(current, limit, obj) {
        if (isTeacher()) {
            obj.teacherId = store.getters.teacherId
        } else {
            obj.isAdmin = true
        }
        return request({
            url: `/course/class/pageClass/${current}/${limit}`,
            method: 'post',
            data: obj
        })
    },
    updateClass(obj) {
        return request({
            url: `/course/class/updateClass`,
            method: 'post',
            data: obj
        })
    },
    addClass(obj) {
        if (isTeacher()) {
            obj.teacherId = store.getters.teacherId
        }
        return request({
            url: `/course/class/addClass`,
            method: 'put',
            params: { ...obj }
        })
    },
    deleteClass(id) {
        return request({
            url: `/course/class/deleteClass/${id}`,
            method: 'delete',
        })
    },
    getClassTeacher(id) {
        return request({
            url: `/course/class/getClassTeacher/${id}`,
            method: 'get',
        })
    },

    addClassTeacher(obj) {
        return request({
            url: `/course/class/addClassTeacher`,
            method: 'put',
            params: { ...obj }
        })
    },
    deleteClassTeacher(id) {
        return request({
            url: `/course/class/deleteClassTeacher/${id}`,
            method: 'delete',
        })
    },
    updateClassTeacher(obj) {
        return request({
            url: `/course/class/updateClassTeacher`,
            method: 'post',
            data: obj
        })
    },
    pageClassUser(classId, current, limit, name) {
        return request({
            url: `/ucenter/user/pageClassUser/${classId}/${current}/${limit}`,
            method: 'get',
            params: { name }
        })
    },
    deleteClassUser(objs) {
        return request({
            url: `/course/class/deleteClassUser`,
            method: 'post',
            data: objs
        })
    },
    addClassUser(objs) {
        return request({
            url: `/course/class/addClassUser`,
            method: 'post',
            data: objs
        })
    }

}